package com.yoso.shop.infrastructure.base.controller;
import com.yoso.shop.infrastructure.constants.base.ResponseCode;


/**
 * @author shizejin
 * @date 2021/11/2
 * @description:
 */
public abstract class AbstractController {

    public <T> BaseResponse<T> success(String msg, T data){
        return new BaseResponse<>(ResponseCode.SUCCESS,data,msg);
    }
    public BaseResponse<Void> success(String msg){
        return new BaseResponse<>(ResponseCode.SUCCESS,null,msg);
    }
    public BaseResponse<Void> error(String msg){
        return new BaseResponse<>(ResponseCode.ERROR,null,msg,false);
    }
    public BaseResponse<Void> result(int result){
        if (result == 1){
            return new BaseResponse<>(ResponseCode.SUCCESS,null,"操作成功");
        }
        return new BaseResponse<>(ResponseCode.ERROR,null,"操作失败",false);
    }
}
